package com.wangsh.usersCenter.users.pojo;

import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
import com.wangsh.usersCenter.common.pojo.BasePojo;

/**
 * 角色表
 * @author 王晨曦
 */
public class ARole extends BasePojo<ARole>
{
	
	/* 主键,自动递增 */
	private int id; 
	 /* 管理员创建id */
	private int createId;
	private AAdmins createAdmins;
	 /* 管理员更新id */
	private int updateId;
	
	private AAdmins updateAdmins;
	 /* 名称 */
	private String name;
	/* 内容:描述 */
	private String content; 
	/* 状态:0:禁用,1:启用 */
	private byte status; 
	 /* 创建时间 */
	private Date createTime;
	/* 更新时间 */
	private Date updateTime; 
	/* 发布时间(用来排序) */
	private Date pubTime; 

	
	/*关联关系*/
	private List<AAdmins> admins;
	
	private String statusStr;
	/*
	 * 方便枚举项在网页上显示出来 键为值(数字),
	 * 值为字符串描述 
	 * 只提供get方法
	 */
	private Map<String,String> enumsMap = new TreeMap<String, String>();
	public Map<String, String> getEnumsMap()
	{
		// 根据状态值获取字符串描述
		ARoleEnum[] roleEnums = ARoleEnum.values();
		for (int i = 0; i < roleEnums.length; i++)
		{
			ARoleEnum roleEnum = roleEnums[i];
			String key = roleEnum.toString() ; 
			enumsMap.put(key + "-" + roleEnum.getStatus() + "", roleEnum.getName());
		}
		return enumsMap;
	}
	

	public int getId()
	{
		return id;
	}

	public void setId(int id)
	{
		this.id = id;
	}

	public int getCreateId()
	{
		return createId;
	}

	public void setCreateId(int createId)
	{
		this.createId = createId;
	}

	public int getUpdateId()
	{
		return updateId;
	}

	public void setUpdateId(int updateId)
	{
		this.updateId = updateId;
	}

	public String getName()
	{
		return name;
	}

	public void setName(String name)
	{
		this.name = name;
	}

	public String getContent()
	{
		return content;
	}

	public void setContent(String content)
	{
		this.content = content;
	}

	public byte getStatus()
	{
		return status;
	}

	public void setStatus(byte status)
	{
		this.status = status;
	}

	public Date getCreateTime()
	{
		return createTime;
	}

	public void setCreateTime(Date createTime)
	{
		this.createTime = createTime;
	}

	public Date getUpdateTime()
	{
		return updateTime;
	}

	public void setUpdateTime(Date updateTime)
	{
		this.updateTime = updateTime;
	}

	public Date getPubTime()
	{
		return pubTime;
	}

	public void setPubTime(Date pubTime)
	{
		this.pubTime = pubTime;
	}

	public List<AAdmins> getAdmins()
	{
		return admins;
	}

	public void setAdmins(List<AAdmins> admins)
	{
		this.admins = admins;
	}

	public String getStatusStr()
	{
		/* 获取所有的枚举项 */
		ARoleEnum[] AUserAroleEnums = ARoleEnum.values();
		for (int i = 0; i < AUserAroleEnums.length; i++)
		{
			ARoleEnum AUserAroleEnum = AUserAroleEnums[i];
			/* 因为枚举项可能有好多,所以需要加一个判断 */
			if(AUserAroleEnum.toString().startsWith("STATUS_"))
			{
				if(AUserAroleEnum.getStatus() == this.getStatus())
				{
					this.statusStr = AUserAroleEnum.getName();
				}
			}
		}
		return statusStr;
	}

	public void setStatusStr(String statusStr)
	{
		this.statusStr = statusStr;
	}

	public AAdmins getCreateAdmins()
	{
		return createAdmins;
	}

	public void setCreateAdmins(AAdmins createAdmins)
	{
		this.createAdmins = createAdmins;
	}

	public AAdmins getUpdateAdmins()
	{
		return updateAdmins;
	}

	public void setUpdateAdmins(AAdmins updateAdmins)
	{
		this.updateAdmins = updateAdmins;
	}
}
